package com.appwoo.txtws.component;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import java.io.PrintStream;

public class UpdateAPN
{
  private Context context;
  public String current = "1";
  public String name = "cmnet";
  private Uri uriApn = Uri.parse("content://telephony/carriers");
  private Uri uriNowApn = Uri.parse("content://telephony/carriers/preferapn");

  public UpdateAPN(Context paramContext)
  {
    this.context = paramContext;
  }

  public void cmwap2Cmnet()
  {
    long l1;
    int i;
    if (NetworkUtils.isCmwap(this.context))
    {
      NetworkUtils.cmwap2Cmnet(this.context);
      l1 = System.currentTimeMillis();
      i = 0;
    }
    while (true)
    {
      if (NetworkUtils.isCmnet(this.context));
      while (i >= 10)
      {
        long l2 = System.currentTimeMillis();
        System.out.println("切换结束，切换花费时间为：" + (l2 - l1) / 1000.0D + "；切换循环次数（如果大于10可能没有切换成功）：" + i);
        if (NetworkUtils.isCmnet(this.context))
          System.out.println("切换结束，网络连接方式为cmnet");
        return;
      }
      try
      {
        Thread.sleep(1000L);
        label112: i++;
      }
      catch (Exception localException)
      {
        break label112;
      }
    }
  }

  public String getCtnetAPN()
  {
    Cursor localCursor = this.context.getContentResolver().query(this.uriApn, null, "numeric = '46003' and user LIKE '%ctnet%'  ", null, null);
    if (localCursor == null)
      return null;
    localCursor.moveToFirst();
    if (!localCursor.isAfterLast())
    {
      localCursor.getString(localCursor.getColumnIndex("apn")).toLowerCase();
      String str = localCursor.getString(localCursor.getColumnIndex("_id"));
      System.out.println("getApn --> str1=" + str);
      return str;
    }
    localCursor.close();
    return null;
  }

  public String getNowApn()
  {
    Cursor localCursor = this.context.getContentResolver().query(this.uriNowApn, null, null, null, null);
    if ((localCursor == null) || (!localCursor.moveToNext()))
    {
      localCursor.close();
      return null;
    }
    String str = localCursor.getString(localCursor.getColumnIndex("_id"));
    System.out.println("getNowApn --> str1=" + str);
    return str;
  }

  public boolean updateApn()
  {
    try
    {
      String str1 = getCtnetAPN();
      String str2 = getNowApn();
      System.out.println("apn---> " + str1 + " & nowApn ---> " + str2);
      if (str1.equals(str2))
        return false;
      ContentResolver localContentResolver = this.context.getContentResolver();
      ContentValues localContentValues = new ContentValues();
      localContentValues.put("apn_id", getCtnetAPN());
      localContentResolver.update(this.uriNowApn, localContentValues, null, null);
      return true;
    }
    catch (Exception localException)
    {
      Logger.v("please set cmwap's apn", String.valueOf(localException));
    }
    return false;
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.component.UpdateAPN
 * JD-Core Version:    0.6.2
 */